<?php

/**
 * 
 * @author Marc Weistroff <marc.weistroff@gmail.com>
 * @version $Id
 *
 */
class baseUrCronActions extends sfActions
{

  public function preExecute()
  {
    $this->addThemeStylesheets();
    $this->addThemeJavascripts();
  }
  
  public function setTemplate($name, $theme = null)
  {
    if(is_null($theme))
    {
      $themeName = get_class(urCron::getInstance()->getTheme());
    }

    $name = sfConfig::get('sf_root_dir').'/plugins/urCronPlugin/plugins/'.$themeName.'Plugin'.'/modules/'.$themeName.'/templates/'.$name;
    
    sfConfig::set('symfony.view.'.$this->getModuleName().'_'.$this->getActionName().'_template', $name);
  }

  protected function addThemeStylesheets()
  {
    $theme = urCron::getInstance()->getTheme();
    foreach($theme->getStylesheets() as $stylesheet)
      $this->getResponse()->addStylesheet( $stylesheet, 'last' );
  }

  protected function addThemeJavascripts()
  {
    $theme = urCron::getInstance()->getTheme();
    foreach($theme->getJavascripts() as $javascript)
      $this->getResponse()->addJavascript( $javascript, 'last' );
  }
}
?>
